% ************************************************************************ 
%     Module name   : Lynx Simulation - Aquisition Mode Run                                                     
%                                                                          
%     Description   : This will run the Aquisition mode on a specific target.                                                    
%                                                                          
%     $Header: /Lynx/SimulationFramework/RSP/IFS/IFSRun.m 2     15/10/08 16:08 Lwabeke $ 
%                                                                          
%    $Author: Lwabeke $	            
%                                                                         
%    $Revision: 2 $                
%                                                                         
% ************************************************************************
%     $History: IFSRun.m $ 
% 
%
% ************************************************************************
%function     [perfHist] = measurePerformance(currentTime, radarState, worldState, param, perfHist)
function      measurePerformance(currentTime, radarState, worldState, param)
global perfHist;

% if (~isstruct(perfHist))
%     perfHist.time(1) = currentTime;
%     perfHist.missedTargets(1) = max([worldState.activeTargets - radarState.TargetList.numTargets, 0]);
%     perfHist.extraTargets(1) = max([radarState.TargetList.numTargets - worldState.activeTargets, 0]);
%     perfHist.search.policy = zeros(size(radarState.setup_select.Search.policy,1), param.endTime*2);
%     perfHist.search.V = zeros(size(radarState.setup_select.Search.V,1), param.endTime*2);
% %     perfHist.search.policy = zeros(param.endTime*2, size(radarState.setup_select.Search.policy,1));
% %     perfHist.search.V = zeros(param.endTime*2, size(radarState.setup_select.Search.V,1));
%     perfHist.search.policy(:,1) = radarState.setup_select.Search.policy';
%     perfHist.search.V(:,1) = radarState.setup_select.Search.V';
% %     perfHist.search.policy(1,:) = radarState.setup_select.Search.policy;
% %     perfHist.search.V(1,:) = radarState.setup_select.Search.V;
%     perfHist.search.chosen_action(1:3,1)= NaN;
%     perfHist.search.chosen_action(radarState.searchSetup.changedInfo.radarSetup.chosen_action,1)= radarState.searchSetup.reward;
%     perfHist.index = 1;
%     
% else
    perfHist.index = perfHist.index + 1;
    perfHist.time(perfHist.index) = currentTime;
    perfHist.missedTargets(perfHist.index) = max([worldState.activeTargets - radarState.TargetList.numTargets, 0]);
    perfHist.extraTargets(perfHist.index) = max([radarState.TargetList.numTargets - worldState.activeTargets, 0]);
%     perfHist.search.policy(perfHist.index,:) = radarState.setup_select.Search.policy;
%     perfHist.search.V(perfHist.index,:) = radarState.setup_select.Search.V;
    perfHist.search.chosen_action(1:3,perfHist.index)= NaN;
    perfHist.search.chosen_action(radarState.searchSetup.changedInfo.radarSetup.chosen_action,perfHist.index)= radarState.searchSetup.reward;
    perfHist.search.policy(:,perfHist.index) = radarState.setup_select.Search.policy.';
    perfHist.search.V(:,perfHist.index) = radarState.setup_select.Search.V.';
    perfHist.search.usedState(radarState.searchSetup.changedInfo.radarSetup.new_state_estimate,perfHist.index) = 1;

%end

